//
//  ThirdVC.m
//  Logistics
//
//  Created by 恩州科技 on 2018/8/4.
//  Copyright © 2018年 puyue.com. All rights reserved.
//

#import "ThirdVC.h"
#import "FindOutTVCell.h"
#import "CargoInformationVC.h"
@interface ThirdVC ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic,strong) UITableView *lookForTV;
@property (nonatomic,strong) UIView *headView;
@property (nonatomic,strong) UILabel *placeLabale;//起始地
@property (nonatomic,strong) UILabel *destinationaLbale;//目的地
@property (nonatomic,strong) UILabel *specificationLabale;//规格

@end

@implementation ThirdVC
-(UITableView *)lookForTV{
    if (!_lookForTV) {
        _lookForTV = [[UITableView alloc]initWithFrame:CGRectMake(0,  kMainTopHeight, kMainScreen_width , kMainScreen_height-kMainTopHeight - GTFixHeightFlaot(37)) style:UITableViewStyleGrouped];
        _lookForTV.backgroundColor = WGColor;
        _lookForTV.showsVerticalScrollIndicator = NO;
        _lookForTV.separatorStyle = UITableViewCellSeparatorStyleNone;
        _lookForTV.dataSource = self;
        _lookForTV.delegate = self;
    }
    return _lookForTV;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.navTitle = @"找货";
    [self.view addSubview:self.lookForTV];
    // Do any additional setup after loading the view.
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 10;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 1;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    FindOutTVCell *cell=[tableView dequeueReusableCellWithIdentifier:@"FindOutTVCell"];
    if (!cell) {
        cell=[[FindOutTVCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"FindOutTVCell"];
    }
    return cell;
}
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    if (section == 0) {
        self.headView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kMainScreen_width,GTFixHeightFlaot(40))];
        self.headView.backgroundColor = [UIColor whiteColor];
        [self createUIView];
        return self.headView;
    }
    return nil;
}
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 0.01;
}
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    return nil;
}

-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    if ( section == 0) {
          return GTFixHeightFlaot(40);
    }else{
        return GTFixHeightFlaot(10);
    }
  
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return GTFixHeightFlaot(60);
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    CargoInformationVC * vc = [CargoInformationVC new];
    [self.navigationController pushViewController:vc animated:YES];
}
-(void)createUIView {
    self.placeLabale = [UILabel labelWithSize:[UIFont systemFontOfSize:12] withColor:[UIColor grayColor] withText:@"起始地"];
    self.placeLabale.textAlignment = NSTextAlignmentCenter;
    self.placeLabale.layer .borderColor = [UIColor grayColor].CGColor;
    self.placeLabale.layer .borderWidth = 1.0;
      //label 点击方法
    [self.placeLabale addTapActionWithBlock:^(UIGestureRecognizer *gestureRecoginzer) {
    }];
    UIImageView * jianTouImage = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"jiantou"]];
    self.destinationaLbale = [UILabel labelWithSize:[UIFont systemFontOfSize:12] withColor:[UIColor grayColor] withText:@"目的地"];
    //label 点击方法
    [self.destinationaLbale addTapActionWithBlock:^(UIGestureRecognizer *gestureRecoginzer) {
        
    }];
    self.destinationaLbale.textAlignment = NSTextAlignmentCenter;
    self.destinationaLbale.layer .borderColor = [UIColor grayColor].CGColor;
    self.destinationaLbale.layer .borderWidth = 1.0;
    self.specificationLabale = [UILabel labelWithSize:[UIFont systemFontOfSize:12] withColor:[UIColor grayColor] withText:@"车长、车型"];
      //label 点击方法
    [self.specificationLabale addTapActionWithBlock:^(UIGestureRecognizer *gestureRecoginzer) {
        
        
    }];
    self.specificationLabale.textAlignment = NSTextAlignmentCenter;
    self.specificationLabale.layer .borderColor = [UIColor grayColor].CGColor;
    self.specificationLabale.layer .borderWidth = 1.0;
    
    UILabel * labelLIn = [UILabel new];
    labelLIn.backgroundColor = WGColor;
    UIImageView * sousuoImage = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"Search"]];
    
    
    [self.headView addSubview:self.placeLabale];
    [self.headView addSubview:jianTouImage];
    [self.headView addSubview:self.destinationaLbale];
    [self.headView addSubview:self.specificationLabale];
    [self.headView addSubview:labelLIn];
    [self.headView addSubview:sousuoImage];
    
    [self.placeLabale mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@(GTFixWidthFlaot(20)));
        make.top.equalTo(@(GTFixHeightFlaot(10)));
        make.height.equalTo(@(GTFixHeightFlaot(15)));
        make.width.equalTo(@(GTFixWidthFlaot(50)));
    }];
    [jianTouImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.placeLabale.mas_right).offset(GTFixWidthFlaot(5));
        make.top.equalTo(@(GTFixHeightFlaot(13)));
        make.height.equalTo(@(GTFixHeightFlaot(10)));
        make.width.equalTo(@(GTFixWidthFlaot(30)));
    }];
    [self.destinationaLbale mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(jianTouImage.mas_right).offset(GTFixWidthFlaot(5));
        make.top.equalTo(@(GTFixHeightFlaot(10)));
        make.height.equalTo(@(GTFixHeightFlaot(15)));
        make.width.equalTo(@(GTFixWidthFlaot(50)));
    }];
    [self.specificationLabale mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(GTFixWidthFlaot(-50));
        make.top.equalTo(@(GTFixHeightFlaot(10)));
        make.height.equalTo(@(GTFixHeightFlaot(15)));
        make.width.equalTo(@(GTFixWidthFlaot(60)));
    }];
    [sousuoImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(GTFixWidthFlaot(-5));
        make.top.equalTo(@(GTFixHeightFlaot(10)));
        make.height.with.mas_equalTo(GTFixHeightFlaot(15));
    }];
    [sousuoImage setContentMode:UIViewContentModeScaleAspectFill];
    sousuoImage.clipsToBounds = YES;
    [labelLIn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(0);
        make.bottom.mas_equalTo(0);
        make.height.mas_equalTo(GTFixWidthFlaot(10));
        make.width.mas_equalTo(kMainScreen_width);
    
    }];
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
